home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Periodicals / develop / develop 4 code / C++ Driver / iacDriver / DriverGlue.a next >
Encoding:
Text File  |  1990-08-27  |  15.0 KB  |  310 lines  |  [TEXT/MPS ]

  1.                 IMPORT         TSDRVRPrime            
  2.                 IMPORT         TSDRVROpen
  3.                 IMPORT         TSDRVRControl            
  4.                 IMPORT         TSDRVRStatus            
  5.                 IMPORT         TSDRVRClose    
  6.  
  7. * From SysEqu.a we get jIODone defined.
  8. * From Traps.a we get _Debugger defined.
  9. * From DriverGlue.incl.a we get the DbgInfo macro defined.  It was just taken from
  10. * Sample.a and all the other macros were deleted.
  11.                 PRINT    PUSH,OFF                                    ; don't print any of this stuff        
  12.                 INCLUDE    'SysEqu.a'
  13.                 INCLUDE    'Traps.a'    
  14.                 INCLUDE    'DriverGlue.incl.a'                ; all our macros and data templates
  15.                 PRINT    POP                                        ; restore the PRINT options
  16.  
  17. *********************************** Main ********************************************
  18. * We have to make this the first entry point in our application because the DRVR       *
  19. * header information must come first.  So, we just put our data defines inside the     *
  20. * "MAIN" procedure and then declare that as our entry point for Mr. Linker.            *
  21. * The bits in the HIGH byte (beware of this -- it bit me the first go-around because*
  22. * I forgot to put them in the HIGH byte), are defined for this DRVR as follows:     *
  23. * Bit 7 (most significant bit)        Undefined        False (0)                                *
  24. * Bit 6                                         dNeedLock        True (1)                                    *
  25. * Bit 5                                         dNeedTime        False (0)                                *
  26. * Bit 4                                         dNeedGoodBye    True (1)                                    *
  27. * Bit 3                                         dStatEnable        True (1)                                    *
  28. * Bit 2                                         dCtlEnable        True (1)                                    *
  29. * Bit 1                                         dWritEnable        True (1)                                    *
  30. * Bit 0 (least significant bit)         dReadEnable        True (1)                                    *
  31. * Which all adds up to: $5F.
  32. * I chose NOT to get periodic time because I really had nothing to do every five     *
  33. * seconds, but I did choose the good-bye kiss because I wanted to be notified when     *
  34. * I was going away.  I don't do anything with it now, but it serves as an example    *
  35. *************************************************************************************
  36.  
  37. HEADERDEF    PROC            EXPORT                                                
  38.                 IMPORT         TSEPrime            
  39.                 IMPORT         TSEOpen
  40.                 IMPORT         TSEControl            
  41.                 IMPORT         TSEStatus            
  42.                 IMPORT         TSEClose    
  43. TSEStartHdr    DC.W            $5F00                                ; Turn the proper bits on
  44.                                                                     ; dNeedLock<6>, dNeedGoodbye<4)
  45.                                                                     ; dReadEnable<3>, dWritEnable<2>
  46.                                                                     ; dCtlEnable<1>, dStatEnable<0>
  47.                 DC.W            $12C                                ; 5 seconds of delay (if dNeedTime = True)
  48.                 DC.W            0                                    ; DRVREMask (for DAs only)
  49.                 DC.W            0                                    ; DRVRMenu (for DAs only)
  50.                 DC.W            TSEOpen-TSEStartHdr            ; Offset to open routine
  51.                 DC.W            TSEPrime-TSEStartHdr            ; Offset to prime routine
  52.                 DC.W            TSEControl-TSEStartHdr        ; Offset to control routine
  53.                 DC.W            TSEStatus-TSEStartHdr        ; Offset to Status routine.
  54.                 DC.W            TSEClose-TSEStartHdr            ; Offset to Close routine.
  55.                 DC.B            '.TimDriver'                    ; Driver name.
  56.                 ALIGN            4                                    ; Align to next long word.
  57.                 ENDP
  58.                     
  59. *********************************** TSEOpen ******************************************
  60. * This routine (and all like it below) performs three basic functions:                     *
  61. * 1) pushing the parameter block (A0), and the pointer to the DCE (A1) on the stack.*
  62. * 2) Testing to see whether the immediate bit was set in the trap word and RTSing    *
  63. * 3) Testing the result in D0.  If it's 1 the operation hasn't completed yet, so we    *
  64. *    just want to RTS.  If it's NOT 1, then we'll jump through jIODone.                    *
  65. * I put the standard procedure header in just so you'd see another example of it in    *
  66. * use.  I found Sample.a to be most helpful in much of what I did here.                    *
  67. *************************************************************************************
  68. TSEOpen        PROC            EXPORT                            ; any source file can use this routine
  69.  
  70. StackFrame    RECORD        {A6Link},DECR                    ; build a stack frame record
  71. Result1        DS.W            1                                    ; function's result returned to caller
  72. ParamBegin    EQU            *                                    ; start parameters after this point
  73. ParamSize    EQU            ParamBegin-*                    ; size of all the passed parameters
  74. RetAddr         DS.L            1                                    ; place holder for return address
  75. A6Link        DS.L            1                                    ; place holder for A6 link
  76. LocalSize    EQU             *                                    ; size of all the local variables
  77.                 ENDR
  78.  
  79.                 WITH            StackFrame                        ; cover our local stack frame
  80.                 LINK            A6,#LocalSize                    ; allocate our local stack frame
  81.                 
  82.                 
  83.                  MOVEM.L         D1-D3/A0-A4,-(A7)               ;Save registers (V1.1A)
  84.                 MOVE.L        A1,-(A7)                            ;Put address of DCE onto stack
  85.                 MOVE.L        A0,-(A7)                            ;Put address of ParamBlock onto stack
  86.                 JSR             TSDRVROpen                        ;Call our routine.
  87.                 ADDQ.W        #$8,A7                            ;Take off A0 and A1 we pushed.
  88.                 ADDA.L        #ParamSize,SP                    ;strip all of the caller's parameters
  89.                 MOVEM.L         (A7)+,D1-D3/A0-A4            ;Restore registers (V1.1A)
  90.                 SWAP            D0                                    ;Save result in MostSig Word
  91.                 MOVE.W        ioTrap(A0),D0                    ;move ioTrap into register so we can test
  92.                 SWAP            D0                                    ;Back again
  93.                 BTST            #(noQueueBit+16), D0            ;Test the bit.
  94.                 BNE.S            OpenRTS                            ;If Z = 0, then noQueueBit set -- branch
  95.  
  96.                 CMP.W            #$1,D0                            ;Compare result with 1
  97.                 BEQ.S            OpenRTS                            ;Not equal to zero so RTS.
  98.                 UNLK            A6                                    ;destroy the link
  99.                 MOVE.L        jIODone,-(A7)                    ;Put jIODone on the stack
  100.                 RTS                                                ;return to the caller
  101.                 
  102. OpenRTS        UNLK            A6                                    ;destroy the link
  103.                 RTS                                                ;return to the caller
  104.                 DbgInfo        TSEOpen                            ;this name will appear in the debugger
  105.                 ENDP
  106.  
  107.  
  108. *********************************** TSEPrime *****************************************
  109. * This routine (and all like it below) performs three basic functions:                     *
  110. * 1) pushing the parameter block (A0), and the pointer to the DCE (A1) on the stack.*
  111. * 2) Testing to see whether the immediate bit was set in the trap word and RTSing    *
  112. * 3) Testing the result in D0.  If it's 1 the operation hasn't completed yet, so we    *
  113. *    just want to RTS.  If it's NOT 1, then we'll jump through jIODone.                    *
  114. * I put the standard procedure header in just so you'd see another example of it in    *
  115. * use.  I found Sample.a to be most helpful in much of what I did here.                    *
  116. *************************************************************************************
  117. TSEPrime        PROC            EXPORT                            ; any source file can use this routine
  118.  
  119. StackFrame    RECORD        {A6Link},DECR                    ; build a stack frame record
  120. Result1        DS.W            1                                    ; function's result returned to caller
  121. ParamBegin    EQU            *                                    ; start parameters after this point
  122. ParamSize    EQU            ParamBegin-*                    ; size of all the passed parameters
  123. RetAddr         DS.L            1                                    ; place holder for return address
  124. A6Link        DS.L            1                                    ; place holder for A6 link
  125. LocalSize    EQU             *                                    ; size of all the local variables
  126.                 ENDR
  127.  
  128.                 WITH            StackFrame                        ; cover our local stack frame
  129.                 LINK            A6,#LocalSize                    ; allocate our local stack frame
  130.                 
  131.                 
  132.                  MOVEM.L         D1-D3/A0-A4,-(A7)               ;Save registers (V1.1A)
  133.                 MOVE.L        A1,-(A7)                            ;Put address of DCE onto stack
  134.                 MOVE.L        A0,-(A7)                            ;Put address of ParamBlock onto stack
  135.                 JSR             TSDRVRPrime                        ;Call our routine.
  136.                 ADDQ.W        #$8,A7                            ;Take off A0 and A1 we pushed.
  137.                 ADDA.L        #ParamSize,SP                    ;strip all of the caller's parameters
  138.                 MOVEM.L         (A7)+,D1-D3/A0-A4            ;Restore registers (V1.1A)
  139.                 SWAP            D0                                    ;Save result in MostSig Word
  140.                 MOVE.W        ioTrap(A0),D0                    ;move ioTrap into register so we can test
  141.                 SWAP            D0                                    ;Back again
  142.                 BTST            #(noQueueBit+16), D0            ;Test the bit.
  143.                 BNE.S            PrimeRTS                            ;If Z = 0, then noQueueBit set -- branch
  144.  
  145.                 CMP.W            #$1,D0                            ;Compare result with 1
  146.                 BEQ.S            PrimeRTS                            ;Not equal to zero so RTS.
  147.                 UNLK            A6                                    ;destroy the link
  148.                 MOVE.L        jIODone,-(A7)                    ;Put jIODone on the stack
  149.                 RTS                                                ;return to the caller
  150.                 
  151. PrimeRTS        UNLK            A6                                    ;destroy the link
  152.                 RTS                                                ;return to the caller
  153.                 DbgInfo        TSEPrime                            ;this name will appear in the debugger
  154.                 ENDP
  155.  
  156.  
  157.  
  158.  
  159. *********************************** TSEControl ***************************************
  160. * This routine (and all like it below) performs three basic functions:                     *
  161. * 1) pushing the parameter block (A0), and the pointer to the DCE (A1) on the stack.*
  162. * 2) Testing to see whether the immediate bit was set in the trap word and RTSing    *
  163. * 3) Testing the result in D0.  If it's 1 the operation hasn't completed yet, so we    *
  164. *    just want to RTS.  If it's NOT 1, then we'll jump through jIODone.                    *
  165. * I put the standard procedure header in just so you'd see another example of it in    *
  166. * use.  I found Sample.a to be most helpful in much of what I did here.                    *
  167. *************************************************************************************
  168. TSEControl    PROC            EXPORT                            ; any source file can use this routine
  169.  
  170. StackFrame    RECORD        {A6Link},DECR                    ; build a stack frame record
  171. Result1        DS.W            1                                    ; function's result returned to caller
  172. ParamBegin    EQU            *                                    ; start parameters after this point
  173. ParamSize    EQU            ParamBegin-*                    ; size of all the passed parameters
  174. RetAddr         DS.L            1                                    ; place holder for return address
  175. A6Link        DS.L            1                                    ; place holder for A6 link
  176. LocalSize    EQU             *                                    ; size of all the local variables
  177.                 ENDR
  178.  
  179.                 WITH            StackFrame                        ; cover our local stack frame
  180.                 LINK            A6,#LocalSize                    ; allocate our local stack frame
  181.                 
  182.                 _Debugger                
  183.                  MOVEM.L         D1-D3/A0-A4,-(A7)               ;Save registers (V1.1A)
  184.                 MOVE.L        A1,-(A7)                            ;Put address of DCE onto stack
  185.                 MOVE.L        A0,-(A7)                            ;Put address of ParamBlock onto stack
  186.                 JSR             TSDRVRControl                    ;Call our routine.
  187.                 ADDQ.W        #$8,A7                            ;Take off A0 and A1 we pushed.
  188.                 ADDA.L        #ParamSize,SP                    ;strip all of the caller's parameters
  189.                 MOVEM.L         (A7)+,D1-D3/A0-A4            ;Restore registers (V1.1A)
  190.                 SWAP            D0                                    ;Save result in MostSig Word
  191.                 MOVE.W        ioTrap(A0),D0                    ;move ioTrap into register so we can test
  192.                 SWAP            D0                                    ;Back again
  193.                 BTST            #(noQueueBit+16), D0            ;Test the bit.
  194.                 BNE.S            ControlRTS                        ;If Z = 0, then noQueueBit set -- branch
  195.  
  196.                 CMP.W            #$1,D0                            ;Compare result with 1
  197.                 BEQ.S            ControlRTS                        ;Not equal to zero so RTS.
  198.                 UNLK            A6                                    ;destroy the link
  199.                 MOVE.L        jIODone,-(A7)                    ;Put jIODone on the stack
  200.                 RTS                                                ;return to the caller
  201.                 
  202. ControlRTS    UNLK            A6                                    ;destroy the link
  203.                 RTS                                                ;return to the caller
  204.                 DbgInfo        TSEControl                        ;this name will appear in the debugger
  205.                 ENDP
  206.  
  207.  
  208.  
  209.  
  210. *********************************** TSEStatus ****************************************
  211. * This routine (and all like it below) performs three basic functions:                     *
  212. * 1) pushing the parameter block (A0), and the pointer to the DCE (A1) on the stack.*
  213. * 2) Testing to see whether the immediate bit was set in the trap word and RTSing    *
  214. * 3) Testing the result in D0.  If it's 1 the operation hasn't completed yet, so we    *
  215. *    just want to RTS.  If it's NOT 1, then we'll jump through jIODone.                    *
  216. * I put the standard procedure header in just so you'd see another example of it in    *
  217. * use.  I found Sample.a to be most helpful in much of what I did here.                    *
  218. *************************************************************************************
  219. TSEStatus        PROC            EXPORT                            ; any source file can use this routine
  220.  
  221. StackFrame    RECORD        {A6Link},DECR                    ; build a stack frame record
  222. Result1        DS.W            1                                    ; function's result returned to caller
  223. ParamBegin    EQU            *                                    ; start parameters after this point
  224. ParamSize    EQU            ParamBegin-*                    ; size of all the passed parameters
  225. RetAddr         DS.L            1                                    ; place holder for return address
  226. A6Link        DS.L            1                                    ; place holder for A6 link
  227. LocalSize    EQU             *                                    ; size of all the local variables
  228.                 ENDR
  229.  
  230.                 WITH            StackFrame                        ; cover our local stack frame
  231.                 LINK            A6,#LocalSize                    ; allocate our local stack frame
  232.                 
  233.                 
  234.                  MOVEM.L         D1-D3/A0-A4,-(A7)               ;Save registers (V1.1A)
  235.                 MOVE.L        A1,-(A7)                            ;Put address of DCE onto stack
  236.                 MOVE.L        A0,-(A7)                            ;Put address of ParamBlock onto stack
  237.                 JSR             TSDRVRStatus                    ;Call our routine.
  238.                 ADDQ.W        #$8,A7                            ;Take off A0 and A1 we pushed.
  239.                 ADDA.L        #ParamSize,SP                    ;strip all of the caller's parameters
  240.                 MOVEM.L         (A7)+,D1-D3/A0-A4            ;Restore registers (V1.1A)
  241.                 SWAP            D0                                    ;Save result in MostSig Word
  242.                 MOVE.W        ioTrap(A0),D0                    ;move ioTrap into register so we can test
  243.                 SWAP            D0                                    ;Back again
  244.                 BTST            #(noQueueBit+16), D0            ;Test the bit.
  245.                 BNE.S            StatusRTS                        ;If Z = 0, then noQueueBit set -- branch
  246.  
  247.                 CMP.W            #$1,D0                            ;Compare result with 1
  248.                 BEQ.S            StatusRTS                        ;Not equal to zero so RTS.
  249.                 UNLK            A6                                    ;destroy the link
  250.                 MOVE.L        jIODone,-(A7)                    ;Put jIODone on the stack
  251.                 RTS                                                ;return to the caller
  252.                 
  253. StatusRTS    UNLK            A6                                    ;destroy the link
  254.                 RTS                                                ;return to the caller
  255.                 DbgInfo        TSEStatus                        ;this name will appear in the debugger
  256.                 ENDP
  257.                 
  258.  
  259.  
  260.  
  261. *********************************** TSEClose *****************************************
  262. * This routine (and all like it below) performs three basic functions:                     *
  263. * 1) pushing the parameter block (A0), and the pointer to the DCE (A1) on the stack.*
  264. * 2) Testing to see whether the immediate bit was set in the trap word and RTSing    *
  265. * 3) Testing the result in D0.  If it's 1 the operation hasn't completed yet, so we    *
  266. *    just want to RTS.  If it's NOT 1, then we'll jump through jIODone.                    *
  267. * I put the standard procedure header in just so you'd see another example of it in    *
  268. * use.  I found Sample.a to be most helpful in much of what I did here.                    *
  269. *************************************************************************************
  270. TSEClose        PROC            EXPORT                            ; any source file can use this routine
  271.  
  272. StackFrame    RECORD        {A6Link},DECR                    ; build a stack frame record
  273. Result1        DS.W            1                                    ; function's result returned to caller
  274. ParamBegin    EQU            *                                    ; start parameters after this point
  275. ParamSize    EQU            ParamBegin-*                    ; size of all the passed parameters
  276. RetAddr         DS.L            1                                    ; place holder for return address
  277. A6Link        DS.L            1                                    ; place holder for A6 link
  278. LocalSize    EQU             *                                    ; size of all the local variables
  279.                 ENDR
  280.  
  281.                 WITH            StackFrame                        ; cover our local stack frame
  282.                 LINK            A6,#LocalSize                    ; allocate our local stack frame
  283.                 
  284.             
  285.                 _Debugger                
  286.                  MOVEM.L         D1-D3/A0-A4,-(A7)               ;Save registers (V1.1A)
  287.                 MOVE.L        A1,-(A7)                            ;Put address of DCE onto stack
  288.                 MOVE.L        A0,-(A7)                            ;Put address of ParamBlock onto stack
  289.                 JSR             TSDRVRClose                        ;Call our routine.
  290.                 ADDQ.W        #$8,A7                            ;Take off A0 and A1 we pushed.
  291.                 ADDA.L        #ParamSize,SP                    ;strip all of the caller's parameters
  292.                 MOVEM.L         (A7)+,D1-D3/A0-A4            ;Restore registers (V1.1A)
  293.                 SWAP            D0                                    ;Save result in MostSig Word
  294.                 MOVE.W        ioTrap(A0),D0                    ;move ioTrap into register so we can test
  295.                 SWAP            D0                                    ;Back again
  296.                 BTST            #(noQueueBit+16), D0            ;Test the bit.
  297.                 BNE.S            CloseRTS                            ;If Z = 0, then noQueueBit set -- branch
  298.  
  299.                 CMP.W            #$1,D0                            ;Compare result with 1
  300.                 BEQ.S            CloseRTS                            ;Not equal to zero so RTS.
  301.                 UNLK            A6                                    ;destroy the link
  302.                 MOVE.L        jIODone,-(A7)                    ;Put jIODone on the stack
  303.                 RTS                                                ;return to the caller
  304.                 
  305. CloseRTS        UNLK            A6                                    ;destroy the link
  306.                 RTS                                                ;return to the caller
  307.                 DbgInfo        TSEClose                            ;this name will appear in the debugger
  308.                 ENDP
  309.                 
  310.                 END